Skip to content

Restore Node 24 (and before) behavior as fs.existsSync() now throws deprecation warning - #474

Merged
AaronFeledy merged 5 commits into
lando:mainfrom
kroh:fix-node24-deprecation-warning
Aug 9, 2026
Merged

Restore Node 24 (and before) behavior as fs.existsSync() now throws deprecation warning#474
AaronFeledy merged 5 commits into
lando:mainfrom
kroh:fix-node24-deprecation-warning

Conversation

@kroh

@kroh kroh commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

The problem

Execution of lando results in the following error:

$ lando setup
[DEP0187] DeprecationWarning: Passing invalid argument types to fs.existsSync is deprecated
  (Use `node --trace-deprecation ...` to show where the warning was created)

What was wrong

Node 24 introduced deprecation DEP0187: fs.existsSync() now warns when passed anything that isn't a string/Buffer/URL. Older Node silently returned false. Lando relies on that old behavior in many places — it calls fs.existsSync(x) where x is often undefined or an object (e.g. plugin dirs that don't exist, config source objects). Each command bootstraps different subsystems, so different call sites fired.

The fix

Rather than guard dozens of individual call sites (fragile and incomplete), I added a single global shim at Lando's entry point at @lando/core/bin/lando:

const _existsSync = fs.existsSync;
fs.existsSync = function(p) {
  if (typeof p !== 'string' && !Buffer.isBuffer(p) && !(p instanceof URL)) return false;
  return _existsSync.apply(this, arguments);
};

This restores the pre-Node-24 semantics (non-path argument returns false), so behavior is unchanged, just no warning.

@netlify

netlify Bot commented Jul 17, 2026

Copy link
Copy Markdown

Deploy Preview for lando-core ready!

Name Link
🔨 Latest commit 179d88c
🔍 Latest deploy log https://app.netlify.com/projects/lando-core/deploys/6a78ef9e2095ab0008f75b68
😎 Deploy Preview https://deploy-preview-474--lando-core.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
1 paths audited
Performance: 73 (🔴 down 15 from production)
Accessibility: 89 (no change from production)
Best Practices: 92 (no change from production)
SEO: 90 (no change from production)
PWA: -
View the detailed breakdown and full score reports
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@AaronFeledy

Copy link
Copy Markdown
Member

Thanks for tracking this down! The Node 24 diagnosis looks right, and it should be possible to fix while retaining Node 20 compatibility. Could we avoid globally monkey-patching Node's fs module, though? That changes existsSync() for every dependency in the process and only applies when core is loaded through bin/lando.

I'd suggest a small explicit helper that returns false for non-path values, then use it at the permissive call sites. A regression test covering invalid values on Node 24 would also be helpful. That preserves the old behavior on Node 20 without changing the global API.

kroh and others added 3 commits August 5, 2026 08:13
Node 24 deprecated passing anything that is not a string, Buffer or URL to
fs.existsSync(). Older Node quietly returned false, which a number of lando
call sites relied on: they pluck optional keys off plugin and config objects
and just want a "is there a file there?" answer. On Node 24 those now emit a
DeprecationWarning to stderr on more or less every lando invocation.

Add utils/exists-sync.js, which returns false for non path-like values and
otherwise defers to fs.existsSync(). Also expose it as utils.existsSync so
plugins can use it.
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Privileged Leia tests skipped

The l337 and lando-v4 Leia suites verify authenticated SSH cloning and need the deploy key, so they do not run for fork pull requests.

After reviewing 179d88cb19803b5e4b006787ed8378259fb4bb3c, a maintainer can run them against it with:

gh workflow run pr-core-tests.yml --repo lando/core -f pull_request=474 -f commit_sha=179d88cb19803b5e4b006787ed8378259fb4bb3c

or from the workflow page using the same inputs. This comment updates when new commits are pushed and the dispatch only accepts the current head commit.

@AaronFeledy
AaronFeledy merged commit 5be3647 into lando:main Aug 9, 2026
75 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants